// import request from '@/utils/request'

// export default {
//     // 列表 
//     getPageList(page,limit,searchObj){
//       return request({
//            url: '/admin/system/role'+page+"/"+limit,
//           method: 'get',
//           params: searchObj 
//       })
//     }
// }

import request from '@/utils/request'
//role分页查询url
// 定义基本的url
const BASE_URL = '/admin/system/sysRole';
const API_URL = '/admin/system/sysUser';

export default {
  // 列表以及分页 
  getPageList(page, limit, searchObj) {
    return request({
      //  url: '/admin/system/role/'+page+"/"+limit,
      url: `${BASE_URL}/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  //删除单个角色
  removeDataById(id) {
    return request({
      url: `${BASE_URL}/remove/${id}`,
      method: 'delete',
    })
  },
  //添加角色
  addRole(role) {
    return request({
      url: `${BASE_URL}/addRole`,
      method: 'post',
      data: role
    })
  },
  //查找单个角色
  findRoleById(id) {
    return request({
      url: `${BASE_URL}/findSysRoleByRoleName/${id}`,
      method: 'get',
    })
  },
  //添加角色
  addRole(role) {
    return request({
      url: `${BASE_URL}/addRole`,
      method: 'post',
      data: role
    })
  },
  //修改角色
  updateRole(role) {
    return request({
      url: `${BASE_URL}/updateRole`,
      method: 'post',
      data: role
    })
  },
  //批量删除
  deleteRoleIds(ids) {
    return request({
      url: `${BASE_URL}/deleteRole`,
      method: 'delete',
      data: ids
    })
  },

  //根据用户id查询用户已分配的角色
  getRolesByUserId(userId) {
    return request({
      url: `${API_URL}/toAssign/${userId}`,
      method: 'get'
    })
  },

  //分配角色
  assignRoles(assginRoleVo) {
    return request({
      url: `${API_URL}/doAssign`,
      method: 'post',
      data: assginRoleVo
    })
  }
}